package API.String.Practises;

public class WordAfterSpace {
    public static void main(String[] args) {
        System.out.println(sub("I want to have lunch"));
    }

    public static String sub(String str) {
        int index = -1;
        for (int i = str.length() - 1; i >= 0; i--) {
            if(str.charAt(i) == ' '){
                index = i;;
                break;
            }
        }
        if(index == -1)
            return "No space";
        else
            return str.substring(index + 1);
    }


}
